Skip to content

Conversation

@savetheclocktower
Copy link
Contributor

Marking this as a draft for now because further testing needs to be done, but this is part of the work needed for pulsar-edit#1272.

This adds the ability to generate a TypeScript template by running ppm init --package <package-name> --syntax typescript. We already allowed people to choose between JavaScript and CoffeeScript when generating a basic package template; this just adds TypeScript as another option.

This TypeScript template does all of what's described in pulsar-edit#1272:

  • Prefers CommonJS versions of dependencies when available, but will transpile ESM to CommonJS.
  • Generates source maps.
  • Allows direct importing of JSON files.

It also has our fork of @types/atom present in devDependencies such that type annotations will be present in one's IDE for the entire atom API. (Install pulsar-ide-typescript to enjoy this feature, of course.)

This needs to be tested in practice before landing. I used this exact structure (albeit constructed by hand rather than generated) for pulsar-hover and it served me well. I've also verified that that package works equally well in mainline Pulsar as it does in PulsarNext.

What's left to test is running ppm init -p foo -s typescript and asserting that it generates a package that “works” out of the box (doesn't fail with syntax or build or load errors). This might be tricky; unlike other template types, this one's entry point is a generated file, so it won't be present after generation until the user runs npm run install and npm run build. The answer might be to make a stub lib/index.js as part of the template so that we can catch this and tell the user what to do.


I also made very slight changes to how ppm init works:

  • When -s/--syntax was omitted, we were assuming the user wanted a CoffeeScript package. This absolutely should not be the default any longer. We can keep supporting it without much hassle, but we should stop advertising it in the help text, too. When -s is omitted, we now assume JavaScript. The specs have been updated accordingly.
  • The result parameter in generateFromTemplate was a classic relic of decaffeinated code. After verifying we weren't actually using that return value for anything, I removed it.

@savetheclocktower savetheclocktower changed the title Add typescript template Add TypeScript template Jul 27, 2025
@savetheclocktower
Copy link
Contributor Author

OK, did some testing around the first-run experience once someone generates a package with this template.

It's quite likely they'll have generated the package by invoking a command from package-generator, so I also replicated the steps that would've been done by that package instead of ppm: doing ppm link /path/to/package and opening the new package root in Pulsar.

Because the package template specifies activationCommands, the package won't actually activate until the user invokes that command. But if they do so without having built their package even once, they'll see this warning:

Screenshot 2025-09-01 at 3 21 39 PM

That should prompt them to install dependencies and run npm run watch, at which point the development process will resemble that of a JS package.

I also tweaked the generated TS so that the user isn't met with a bunch of linter errors immediately.

@savetheclocktower
Copy link
Contributor Author

I think I meant to make this a draft, but can't find any evidence that it ever was a draft. However, now that I've done the manual testing I promised, pretend I just took this out of draft!

@savetheclocktower
Copy link
Contributor Author

As usual, the CI needs a major medical intervention because we committed the crime of relying on something.

@DeeDeeG
Copy link
Member

DeeDeeG commented Nov 5, 2025

I did a CI fixup in #154. If you like, I can rebase this branch on top of that, or fix the merge conflict.

I'm not super involved with TypeScript, but I'm inclined to believe you that this is a good way to set up [a template for] new TypeScript packages. (And it can always be improved later on down the line.) CI passes with updated tests, so that's nice.

@savetheclocktower
Copy link
Contributor Author

I did a CI fixup in #154. If you like, I can rebase this branch on top of that, or fix the merge conflict.

Yeah, feel free to update this PR! I'm deep in some other silly pursuit at the moment.

…and also:

* Remove a decaffeination idiom
* Make JavaScript the default for `ppm init -p` instead of CoffeeScript
* Stop advertising CoffeeScript support in the help text (without dropping support for it)
@DeeDeeG DeeDeeG force-pushed the add-typescript-template branch from 70bf357 to 42ce87e Compare November 7, 2025 02:44
@DeeDeeG
Copy link
Member

DeeDeeG commented Nov 7, 2025

Yeah, feel free to update this PR!

It is done. 👍

@savetheclocktower
Copy link
Contributor Author

OK, merged the big Node upgrade into this PR. This isn't something that absolutely must make it into ppm before the Electron 30 upgrade, but while we're stress-testing the upcoming release candidate, I figure we might as well kick the tires on this one! It adds a new feature that cannot regress any existing features, so I think the risk is pretty low.

Copy link
Member

@DeeDeeG DeeDeeG left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did I really not formally approve this yet? Okay, approved.

Would love a second pair of review eyes from someone who uses TypeScript, if that is forecoming, but... is it? I don't know.

Anyway, the intent is good, and nothing obvious jumps out to me as being wrong.

Moving to JS by default and demoting CoffeeScript heavily is the sort of thing that might be controversial if CoffeeScript weren't basically gone from popular use and largely superseded by recent JSisms.

FWIW: ppm init --package [name] --syntax typescript does work for me locally on this branch. So that's good!

@savetheclocktower savetheclocktower merged commit b49194b into pulsar-edit:master Nov 23, 2025
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants